<%--                                                                       --%>
<%-- Copyright (c) 2001-2004 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries.                       --%>
<%--                                                                       --%>

<%@ page import = "java.util.*" %>
<%@ page import = "org.apache.struts.util.RequestUtils" %>


<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> 
<%@ taglib uri="/WEB-INF/bv-html.tld" prefix="bvhtml" %>


<script language="javascript">

<% 
  String nextAction = "/cs/announcementAttachmentAdd.do";
  String nextPage = RequestUtils.computeURL(pageContext,
                                           null,
                                           null,
                                           nextAction,
                                           null,
                                           null,
                                           false);
  String relativeDir = "/";
  // + annEditForm.getServiceName() + "/microsite/" + annEditForm.getMicrositeId(); 
%>


function onClickSave(theForm) {
  if (validateForm(theForm)) {
    theForm.submit();
  }
}

function openwin(file) {
  var win = window.open(file , "NewWindow", 'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=450,height=338');
  win.focus();
}

function onFileInputFocus()
{
   return document.annEditForm.newFile.focus();
}

function onClickDeleteAnnouncement(theForm, url) {
   if (confirm("<bean:message key="cs.confirm.delete.announcement"/>")) {
     theForm.action=url;
     theForm.submit();
   }
   else {
     return false;
   }
}

//
// Trims leading blanks.
//
function stringLeftTrim(s)
{
   return s.replace(/^ +/, "");
}

//
// Trims trailing blanks.
//
function stringRightTrim(s)
{
   return s.replace(/ +$/, "");
}

//
// Trims leading and trailing blanks.
//
function stringTrim(s)
{
   return stringRightTrim(stringLeftTrim(s));
}

//
// Validate the user's entries.
//
function validateForm(theForm)
{
   var annName = stringTrim(theForm.name.value);

   if (annName == "")
   {
      alert("<bean:message key="cs.error.announcement.name"/>");
      return false;
   }

   var annDesc = stringTrim(theForm.description.value);
   if (annDesc.length > 2000) 
   {
      alert("<bean:message key="cs.error.announcement.description"/>");
      return false;
   }

   var groupIndex = theForm.groupIds.selectedIndex;

   if (groupIndex == -1)
   {
      alert("<bean:message key="cs.error.announcement.read.group"/>");
      return false;	
   }

   var attachName = stringTrim(theForm.attName.value);
   var attachFile = stringTrim(theForm.attOriginalFileName.value);

   if (attachName != "" || attachFile != "")
   {
      alert('<bean:message key="cs.error.attachment.add.more"/>');
      return false;
   }

   theForm.name.value = annName;
   theForm.description.value = annDesc;
   return true;
}

</script>

<!-- Zone 5 starts here.  -->
      
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" 
       summary="content area">
  <tr>
    <td valign="top">
    
    <!--start microsite logo and name here-->
      <div class="pageTitle">
        <%@ include file="/cs/microsite/micrositeNaviInfo.jsp" %>
      </div> 
    <!--end microsite logo and name here-->


<!--  BEGIN form { announcement } ----------------------------- -->


<html:form action="/cs/announcementSave.do">
  <bvhtml:hiddenList name="micrositeNaviInfoView" property="urlParams" scope="request"/>
  <html:hidden property="sequenceKey"/>
  <input type="hidden" name="parentContentType" value="328"/>

<!--start title bar here-->

  <div class="pageSubtitle">
    <span class="left">
      <bean:write name="announcementEditView" property="pageTitle"/>
    </span>
    <span class="right">
	&nbsp;
    </span>
  </div>       
  
<!--end title bar here-->
  
  <div class="blockWrap">
  
<!-- start Page Instructions -->
    <div class="pageInstructions">
      <logic:equal name="csAnnouncementEditForm" property="announcementId" value="0">
          <bean:message key="cs.announcement.new.note"/>
      </logic:equal>
      <logic:notEqual name="csAnnouncementEditForm" property="announcementId" value="0">
          <bean:message key="cs.announcement.edit.note"/>
      </logic:notEqual>
    </div>
    <!-- End Page Instructions -->
        
    <!--start main content area here-->
    <table class="labelForm" width="100%" border="0" cellspacing="0" 
           cellpadding="0" summary="Announcement Information">
             
      <tr> 
        <td nowrap width="20%" class="label"><bean:message key="cs.name"/>*: </td>
        <td width="80%" nowrap class="labelField"> 
          <html:text property="name" size="30" maxlength="80"/>
        </td>
      </tr>
      <tr> 
        <td nowrap width="20%" class="label"> 
          <bean:message key="cs.message"/>: 
        </td>
        <td width="80%" nowrap class="labelField"> 
           <html:textarea property="description" cols="30" rows="4"/>
        </td>
      </tr>
      <logic:equal name="micrositeNaviInfoView" property="micrositeTemplatePhaseFlag" value="true">
      <bean:define id="allPhasesList" name="announcementEditView" property="allPhasesList" />
        <tr> 
          <td nowrap width="20%" class="label"><bean:message key="cs.phase"/>*:</td>
          <td width="80%" nowrap class="labelField"> 
            <html:select property="newPhaseId" size="1">
              <html:options name="announcementEditView" collection="allPhasesList" property="id" labelProperty="name" />
            </html:select>
          </td>
        </tr>
      </logic:equal>
      
      <logic:equal name="micrositeNaviInfoView" property="micrositeTemplatePhaseFlag" value="false">
       <html:hidden property="phaseId"/>
      </logic:equal>
 
    <tr> 
       <td width="20%" class="label"><bean:message key="cs.read.access.groups"/>*:<br>
       </td>
       <td nowrap width="80%" class="labelField">
         <html:select property="groupIds" size="4" multiple="true">
            <html:optionsCollection name="announcementEditView" property="availableGroups"/>
         </html:select>
       </td>
     </tr>
     
    <tr> 
      <td nowrap width="20%" class="label"><bean:message key="cs.owner"/>:</td>
      <td nowrap width="80%" class="labelField">
        <bean:write name="announcementEditView" property="ownerName"/>
      </td>
    </tr>
  </table>  
<% // Need to define the attachment form bean for the included JSP %>
   <!-- Start Display attachment. -->
    <script language="JavaScript">
      var nextPage = '<html:rewrite page="/cs/announcementAttachmentAdd.do" />';
      var attachmentDeleteAction = '<html:rewrite page="/cs/announcementAttachmentDelete.do" />';

      <logic:equal name="csAnnouncementEditForm" property="announcementId" value="0">
        var nextActionAfterCancel = '/cs/announcementList.do';
        var nextActionAfterReset = '/cs/announcementNew.do';
      </logic:equal>
      <logic:notEqual name="csAnnouncementEditForm" property="announcementId" value="0">
        var nextActionAfterCancel = '/cs/announcementView.do';
        var nextActionAfterReset = '/cs/announcementEdit.do';
      </logic:notEqual>
    </script>
    
    <bean:define id="formBeanUsed" name="csAnnouncementEditForm" toScope="request" />
    <%@ include file="/cs/microsite/attachment/attachmentEdit.jsp" %>
    <!-- end of attachments secion -->

   <!--start cancel, reset, save bar area here-->
    <div class="pageButtonWrap" align="right">
      <html:button styleClass="pageButton" property="resetBtn" 
                  titleKey="button.reset" onclick="return resetAttachment(this.form)">
          <bean:message key="button.reset"/>
      </html:button>
	&nbsp;&nbsp;              
      <html:button styleClass="pageButton" property="cancelBtn" 
             titleKey="button.cancel" onclick="return cancelClearAttachment(this.form)">
        <bean:message key="button.cancel"/>
      </html:button>
      
      <input type="button" class="pageButton" name="saveBtn"
             titleKey="button.save" onclick="return onClickSave(this.form)"
             value='<bean:message key="button.save"/>'>
                     
    </div>     
    <!--end cancel, reset, save bar area here-->
    </html:form>
    
    </div>
    
    </td>
  </tr>
</table>
<!--end zone 5 content here --> 

